package com.cj.service.impl;

import com.cj.dao.UserDao;
import com.cj.entity.User;
import com.cj.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Created by chenjie on 2017/5/6.
 */
@Service
public class userServiceImpl implements userService {

    @Autowired
    private UserDao userDao;
    @Autowired
    private RedisTemplate<String, User> redisTemplate;

    public String select(){
        List<Map<String, Object>> select = userDao.select();
        List<User> maps = userDao.selectToUser();
        User user = maps.get(0);
        ValueOperations<String, User> vop = redisTemplate.opsForValue();
        User hahaha = vop.get("hahaha");
        if(hahaha!=null) return "";
        vop.set("hahaha",user);
        return "";
    }
}
